package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MaterialPackege;
import com.ruoyi.system.service.IMaterialPackegeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2025-02-20
 */
@RestController
@RequestMapping("/system/packege")
@Api(tags = "物料管理")
public class MaterialPackegeController extends BaseController
{
    @Autowired
    private IMaterialPackegeService materialPackegeService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:packege:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestBody MaterialPackege materialPackege, @RequestParam Integer pageNum, @RequestParam Integer pageSize)
    {

        List<MaterialPackege> list = materialPackegeService.selectMaterialPackegeList(materialPackege,pageNum,pageSize);
        Long total = materialPackegeService.selectMaterialPackegeCount(materialPackege);
        return getDataTable(list,total);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:packege:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MaterialPackege materialPackege)
    {
        List<MaterialPackege> list = materialPackegeService.selectMaterialPackegeAll(materialPackege);
        ExcelUtil<MaterialPackege> util = new ExcelUtil<MaterialPackege>(MaterialPackege.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:packege:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(materialPackegeService.selectMaterialPackegeById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:packege:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MaterialPackege materialPackege)
    {
        return toAjax(materialPackegeService.insertMaterialPackege(materialPackege));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:packege:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MaterialPackege materialPackege)
    {
        return toAjax(materialPackegeService.updateMaterialPackege(materialPackege));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:packege:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(materialPackegeService.deleteMaterialPackegeByIds(ids));
    }
}
